package com.mojo.jvm.jvm_02_classloader;

/**
 * @author <a href="mailto:sjj@jianzhimao.com">mojo</a>
 * copyright (C), 2013-2022, 广州九尾信息科技有限公司
 * @date 2022/10/18 16:37
 */
public class ClassLoaderDemo {
    public static void main(String[] args) throws ClassNotFoundException {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        ClassLoader parent = loader.getParent();
        System.out.println(loader);
        System.out.println(parent);
        System.out.println(parent.getParent());
        System.out.println("==================");
        //验证 java开头的类使用的类加载器
        System.out.println(String.class.getClassLoader());
        Class<?> base = loader.loadClass("com.mojo.jvm.jvm_01_javassit.Base");
        System.out.println(base);
        // forName方法类加载会执行静态代码块
        Class<?> base1 = Class.forName("com.mojo.jvm.jvm_01_javassit.Base");
        System.out.println(base1);
    }

}
